@echo off
echo ======================================================
echo Neural-SLAM Enhancement Pipeline - Windows Setup
echo ======================================================

REM Check if conda is available
where conda >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Conda is not available. Please install Anaconda/Miniconda first.
    pause
    exit /b 1
)

echo.
echo 📦 Setting up Conda environment...
echo.

REM Create conda environment
call conda create -n neural_slam_enhanced python=3.8 -y
if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Failed to create conda environment
    pause
    exit /b 1
)

echo.
echo ⚡ Activating environment and installing PyTorch...
echo.

REM Activate environment and install PyTorch
call conda activate neural_slam_enhanced
call conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Failed to install PyTorch
    pause
    exit /b 1
)

echo.
echo 📚 Installing additional requirements...
echo.

REM Install additional requirements
call pip install -r requirements_enhanced.txt
if %ERRORLEVEL% NEQ 0 (
    echo ERROR: Failed to install requirements
    pause
    exit /b 1
)

echo.
echo 🧪 Testing environment setup...
echo.

REM Test environment
python test_env.py
if %ERRORLEVEL% NEQ 0 (
    echo WARNING: Environment test had issues. Check the output above.
    echo You may still be able to proceed depending on the specific errors.
    pause
)

echo.
echo ======================================================
echo Setup completed! Choose an option:
echo ======================================================
echo 1. Run complete pipeline (may take 12+ hours)
echo 2. Run quick test pipeline (1-2 hours)
echo 3. Run specific phase
echo 4. Just generate paper results
echo 5. Exit
echo.

set /p choice="Enter your choice (1-5): "

if "%choice%"=="1" (
    echo.
    echo 🚀 Starting complete pipeline...
    python run_complete_pipeline.py
) else if "%choice%"=="2" (
    echo.
    echo ⚡ Starting quick pipeline...
    python run_complete_pipeline.py --quick-mode
) else if "%choice%"=="3" (
    echo.
    echo Available phases: 1, 2, 3, 4, 5, 6, 7
    set /p phase="Enter phase number: "
    python run_complete_pipeline.py --phase %phase%
) else if "%choice%"=="4" (
    echo.
    echo 📄 Generating paper results...
    python generate_paper_results.py
) else (
    echo.
    echo 👋 Exiting. Environment is ready for manual use.
    echo To activate: conda activate neural_slam_enhanced
)

echo.
echo ======================================================
echo Pipeline execution completed!
echo ======================================================
echo Check the generated files in:
echo - ./paper_results/ - LaTeX tables and figures
echo - ./experiments/ - Training logs and models
echo - ./logs/ - Detailed logs
echo ======================================================

pause
